[Bugfix] Register VLLM_BATCH_INVARIANT in envs.py to fix spurious unknown env var warning#35007
Conversation
Signed-off-by: Ranran <1012869439@qq.com>
There was a problem hiding this comment.
Code Review
The pull request correctly registers the VLLM_BATCH_INVARIANT environment variable in vllm/envs.py to suppress the 'Unknown vLLM environment variable' warning. This is a necessary step for maintaining a clean log output when this feature is used. However, the implementation of the boolean conversion for this variable is less robust than the one it replaces in batch_invariant.py and could lead to a crash if a non-integer value (like 'true') is provided. Additionally, there is now duplicated logic for reading this environment variable between envs.py and batch_invariant.py, which should ideally be consolidated if circular dependencies can be avoided.
| "VLLM_BATCH_INVARIANT": lambda: bool( | ||
| int(os.getenv("VLLM_BATCH_INVARIANT", "0")) | ||
| ), |
There was a problem hiding this comment.
The current implementation using int() will raise a ValueError and crash the application if the environment variable is set to a non-integer value such as "true" or "false". This is a regression in robustness compared to the original implementation in batch_invariant.py which handled this error gracefully. It is recommended to use a more robust parsing pattern consistent with other variables in this file (e.g., VLLM_USE_PRECOMPILED).
| "VLLM_BATCH_INVARIANT": lambda: bool( | |
| int(os.getenv("VLLM_BATCH_INVARIANT", "0")) | |
| ), | |
| "VLLM_BATCH_INVARIANT": lambda: os.getenv("VLLM_BATCH_INVARIANT", "0") | |
| .strip() | |
| .lower() | |
| in ("1", "true"), |
There was a problem hiding this comment.
I think this is overcomplicating things. my style is consistent with other envs. So it should be fine.
|
Hi @WindChimeRan, the pre-commit checks have failed. Please run: uv pip install pre-commit
pre-commit install
pre-commit run --all-filesThen, commit the changes and push to your branch. For future commits, Tip Is
|
Signed-off-by: Ranran <1012869439@qq.com>
yewentao256
left a comment
There was a problem hiding this comment.
Thanks for the work! The idea looks good
Please update the logic in _read_vllm_batch_invariant and related usage
Signed-off-by: Ranran <1012869439@qq.com>
Signed-off-by: ran <hzz5361@psu.edu>
Head branch was pushed to by a user without write access
yewentao256
left a comment
There was a problem hiding this comment.
Please solve the pre-commit issue so that we can land this pr
|
This pull request has merge conflicts that must be resolved before it can be |
…variant-env Signed-off-by: ran <hzz5361@psu.edu>
03ab562 to
0843198
Compare
|
@yewentao256 All green! |
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com> Signed-off-by: Monishver Chandrasekaran <monishverchandrasekaran@gmail.com>
Update to match upstream changes from commit dc6908a (vllm-project#35007): - Remove import of vllm_is_batch_invariant - Change vllm_is_batch_invariant() to envs.VLLM_BATCH_INVARIANT This fixes the inconsistency where origin/main uses the envs approach but our branch was still using the old function call. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: khairulkabir1661 <khairulkabir1661@users.noreply.github.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com> Signed-off-by: Nithin Chalapathi <nithin.ch10@gmail.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com> Signed-off-by: Vinay Damodaran <vrdn@hey.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com> Signed-off-by: EricccYang <yangyang4991@gmail.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com> Signed-off-by: rishitdholakia13 <rishit+github@cohere.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com> Signed-off-by: Rishi Puri <riship@nvidia.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
…nown env var warning (vllm-project#35007) Signed-off-by: Ranran <1012869439@qq.com> Signed-off-by: Ranran <hzz5361@psu.edu> Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
similar fix to my upstream PR: vllm-project/vllm#35007 * register all env vars in a vllm way * dedicated `envs.py` * update relevant unit tests ### The problem **before**: unregistered envs warning <img width="1168" height="259" alt="image" src="https://github.com/user-attachments/assets/e447e7cc-d3bc-446e-9f5f-22850223f62b" /> **after**: the warning disappeared. --------- Signed-off-by: ran <hzz5361@psu.edu> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Purpose
Register
VLLM_BATCH_INVARIANTinenvs.pyto suppress spurious warning.VLLM_BATCH_INVARIANTis read viaos.getenv()inbatch_invariant.pybut is never registered inenvs.py'senvironment_variablesdict. This causesvalidate_environ()to emit an "Unknown vLLM environment variable detected" warning every time the feature is used:This PR adds the env var to both the type stub and the registry dict in
envs.py.Test Plan
Verify no "Unknown vLLM environment variable" warning is emitted.
Test Result
Before: warning is emitted on every invocation with
VLLM_BATCH_INVARIANTset.After: no warning.
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.